import com.vividsolutions.jts.geom.*;
import com.vividsolutions.jts.geom.util.*;
import com.vividsolutions.jts.algorithm.*;

// ########### //
// Common Code //
// ########### //
Integer devicesPerSite = 50
Integer mxPerAssignment = 75
Integer locationsPerAssignment = 40
Integer minTemp = 80
Integer warnTemp = 160
Integer errorTemp = 180
Integer criticalTemp = 190
Integer maxTemp = 200

def randomId = { java.util.UUID.randomUUID().toString() }
def randomItem = { items ->
	items.get((int)(Math.random() * items.size()))
}

// #################### //
// Create Site and Zone //
// #################### //
def site = deviceBuilder.newSite 'bb105f8d-3150-41f5-b9d1-db04965668d3', 'defalut fire Site'

site.withDescription '''A construction site with many high-value assets that should not be taken offsite. 
The system provides location tracking for the assets and notifies administrators if any of the assets move 
outside of the general site area or into areas where they are not allowed.'''

site.withImageUrl 'https://s3.amazonaws.com/sitewhere-demo/construction/construction.jpg'
site.openStreetMap 34.10469794977326, -84.23966646194458, 15
site = deviceBuilder.persist site
logger.info "[Create Site] ${site.name}"

// Create zone associated with site.
def zone = deviceBuilder.newZone 'Construction Site' withBorderColor('#017112') withFillColor('#1db32e') withOpacity(0.4)
zone.coord(34.10260138703638, -84.24412965774536) coord(34.101837372446774, -84.24243450164795)
zone.coord(34.101517550337825, -84.24091100692749) coord(34.10154953265732, -84.23856675624847)
zone.coord(34.10153176473365, -84.23575580120087) coord(34.10409030732968, -84.23689305782318)
zone.coord(34.104996439280704, -84.23700034618376) coord(34.10606246444614, -84.23700034618376)
zone.coord(34.107691680235604, -84.23690915107727)
zone = deviceBuilder.persist site, zone

// ############################ //
// Create Device Specifications //
// ############################ //
// #################### //
// Create Device Groups //
// #################### //
// Create Devices and Assignments //
// ############################## //

